All Questions
Tagged with react-contextauthentication
48 questions
0votes
0answers
18views
react oidc context signinpopup always returns an error that the pop up was closed
I'm using import react-oidc-context to auth with my aws cognito. I'm trying to use the .signinPopup function but whenever the pop up opens I'm getting an error "Popup closed by user" ...
0votes
1answer
47views
Fetch user data once loaded Next.js
I'm attempting to fetch the data from user once the page loads. Although, currently when there is any route changes, it triggers my useEffect and calls the fetch user endpoint which causes my loading ...
2votes
1answer
66views
How can I prevent the accessibility of a react component once the user has been logged out of the private route in react?
I have been working on really simple react pages just to clear my concepts. In this, i have a simple authentication method by storing the login info in users.json file (This is just for the sake of ...
-1votes
1answer
1kviews
Can any one explain how i can manage context with tanstack router?
AuthcontextProvider.tsx import {ReactNode, useEffect, useState} from 'react'; import {AuthContext} from './AuthContext'; import {Token, User} from '@/types'; import {QUERY_KEYS} from '@/lib/react-...
0votes
1answer
92views
Update react context without refreshing page on state update
I am currently building an app using following stack: Next.js Node.js, Express.js PostgreSQL. I build an authentication using JWT HTTPOnly cookie. Below is my code to how I do login, logout and verify ...
0votes
1answer
56views
useContext Cannot read properties of undefined (reading 'name')
I am saving a user object into the browser cookies and want to read its properties in the frontend. The error I am getting is: Cannot read properties of undefined (reading 'name') TypeError: Cannot ...
0votes
1answer
141views
On opening app first login screen is loaded and then moving to Home screen in expo react native
I React context API for persist login using JWT token for my APP. When closing and opening the app at that time first login screen loading then home screen, How to fix the delay. Same thing happening ...
0votes
1answer
66views
Problem in Redirecting Users to Login Page If Not Authenticated and Redirect to Main App After Successful Login
Here is my Mainapp.js: import React, { useContext, useEffect, useState } from "react"; import { IoIosAddCircle } from "react-icons/io"; import { FaUserCircle } from "react-...
-1votes
1answer
324views
TS-React: Type 'number | null' is not assignable to type 'number'. Type 'null' is not assignable to type 'number'.ts(2322)
I want to use following API call createWorkout({ workoutName, userId });. When I hover on userId, I get the warning: Type 'number | null' is not assignable to type 'number'. Type 'null' is not ...
1vote
1answer
284views
How to Keep User Data Persistent in React with React-Router-Dom and Context?
I'm working on the login of a client-side application. I'm using React with TypeScript. I'm using react-router-dom. I'm using Context to store the logged-in user's data, but when I refresh the page, ...
0votes
1answer
434views
Redirect to home if user is null in NextJS 13 with auth context
i am implementing auth system with jwt in my next app. But i am having an issue when i work with protected page, here is my profile page (protected page): 'use client' import { useContext, useEffect } ...
1vote
1answer
147views
Which hook is more suitable for authorization verification?
I'm wondering how the method will be the most correct from the point of view of logic. I want to check authorization for rendering components , but now useEffect only works there when the page is ...
2votes
0answers
544views
Protected routes in React using httponly JWT
I'm trying to wrap my head around authentication in react and I'm writing a pet project. In my react app I'm receiving an http-only JWT from the server when the user logs in. Since it's marked as http-...
0votes
1answer
861views
useContext x is not a function
So I'm trying to get the current user from the backend (using supabase, react) to determine wether I should show the profile or the login prompt when they click the user icon. I've tried using some ...
1vote
0answers
13views
React AuthContext renders after RequireAuth component [duplicate]
Any help or advice on this issue would be much appreciated! I am creating an app with react router and TypeScript and I am using an AuthContext store my user data. I am having an issue when trying to ...